package json;

import java.util.HashMap;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;

import bean.DaShuai;
public class jsonObjectSample {

	public static void main(String[] args) {
		//jsonSsmple();
		//jsonMap();
		//jsonBean();
		String a = "pappa.addfds";
		String[] split = a.split("\\.");
		for (String string : split) {
			System.out.println(string);
		}
	}

	private static void jsonBean() {
		DaShuai lidashuai = new DaShuai();
		lidashuai.setAge(22.3);
		lidashuai.setBirthday("2016-09.09");
		lidashuai.setComment("这是一个注释");
		lidashuai.setName("李大帅");
		lidashuai.setHas_girlfriend(false);
		lidashuai.setCar(null);
		lidashuai.setHouse(null);
		lidashuai.setMajor(new String[] {"挖掘机","编程"});
		lidashuai.setSchool("蓝翔");
		System.out.println(new JSONObject(lidashuai));
	}

	private static void jsonMap() {
		Map<String, Object> lidashuai = new HashMap<String,Object>();
		Object nullObiect = null;
		lidashuai.put("name","李大帅");
		lidashuai.put("age", 22.3);
		lidashuai.put("birthday", "2016-09.09");
		lidashuai.put("school", "蓝翔");
		lidashuai.put("major", new String[]{"挖掘机","编程"});
		lidashuai.put("has_girlfriend", false);
		lidashuai.put("car", nullObiect);
		lidashuai.put("house", nullObiect);
		lidashuai.put("comment", "这是一个注释");
		JSONObject jsonObject = new JSONObject(lidashuai);
		System.out.println(jsonObject.toString());
		
	}

	private static void jsonSsmple() {
		JSONObject lidashuai = new JSONObject();
		Object nullObiect = null;
		try {
			lidashuai.put("name","李大帅");
			lidashuai.put("age", 22.3);
			lidashuai.put("birthday", "2016-09.09");
			lidashuai.put("school", "蓝翔");
			lidashuai.put("major", new String[]{"挖掘机","编程"});
			lidashuai.put("has_girlfriend", false);
			lidashuai.put("car", nullObiect);
			lidashuai.put("house", nullObiect);
			lidashuai.put("comment", "这是一个注释");
			System.out.println(lidashuai.toString());
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	
	
}
